package net.zjitc.dao.CategorySecond.impl;

import net.zjitc.dao.CategorySecond.CategorySecondDao;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/3/15.
 */
@Repository
public class CategorySecondDaoImpl implements CategorySecondDao {
    @Resource
    private SessionFactory sessionFactory;
    protected Session getSession(){
        Session session = sessionFactory.getCurrentSession();
        return session;
    }

    @Override
    public List findByCid(Integer cid) {
        return getSession().createQuery(
                "from Categorysecond c where c.category.cid=?")
                .setParameter(0,cid)
                .list();
    }

    @Override
    public List findAll() {
        return getSession().createQuery(
                "from Categorysecond ")
                .list();
    }
}
